import React, { Suspense, useState } from 'react'

const Nowplaying = React.lazy(() => import('./components/Nowplaying'))
const Commingsoon = React.lazy(() => import('./components/Commingsoon'))

export default function App() {
    const [type, setType] = useState(1)
    return (
        <div>
            <button onClick={() => setType(1)}>正在热映</button>
            <button onClick={() => setType(2)}>即将上映</button>
            <Suspense fallback={<div>正在加载中......</div>}>
                {
                    type === 1 ?
                        <Nowplaying></Nowplaying>
                        :
                        <Commingsoon></Commingsoon>
                }
            </Suspense>
        </div>
    )
}

